﻿
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap.css">
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap-responsive.css">
<link rel="stylesheet" type="text/css" href="/static/css/bootstrap-overrides.css">
<link rel="stylesheet" type="text/css" href="/static/css/lib/font-awesome.css">

<link rel="stylesheet" type="text/css" href="/static/css/layout.css">
<link rel="stylesheet" type="text/css" href="/static/css/elements.css">
<link rel="stylesheet" type="text/css" href="/static/css/icons.css">
<link rel="stylesheet" type="text/css" href="/static/css/css.css">
<link rel="stylesheet" type="text/css" href="/static/css/compiled/user-profile.css" media="screen" />

<script src="/static/js/jquery-1.8.3.min.js"></script>
<script src="/static/js/bootstrap.min.js"></script>
<script src="/static/js/theme.js"></script>
<script src="/static/js/layer/layer.js"></script>
<script src="/static/js/base.js"></script>

<style>
    .alert-msg {
        display: none;
        margin-left: 5px;
    }
</style>
<div class="container-fluid">
    <div id="pad-wrapper" class="form-page">

        <div class="row-fluid head">
            <div class="span12">
                <h4>添加商户</h4>
            </div>
        </div>

        <div class="row-fluid withdraw">
            <form id="form_data">
                <div class="field-box withdrawApply">
                    <label>商户手机：</label>
                    <input class="span6" type="text" id="MobilePhone" name="MobilePhone" placeholder="请输入商户手机" value="" /><span class="alert-msg"></span>
                </div>

                <div class="field-box withdrawApply">
                    <label>商户名称：</label>
                    <input class="span6" type="text" id="MerName" name="MerName" placeholder="请输入商户名称" value="" /><span class="alert-msg"></span>
                </div>
                <div class="field-box">
                    <label>签约类型：</label>
                    <input style="margin-bottom:5px;width:30px;height:15px;" type="radio" name="AccountType" value="0" checked />个人
                    <input style="margin-bottom:5px;width:30px;height:15px;" type="radio" name="AccountType" value="1" />企业
                </div>
                <div class="field-box withdrawApply">
                    <label>登录密码：</label>
                    <input class="span6" type="password" id="Pass" name="Pass" placeholder="请输入登录密码" value="" /><span class="alert-msg"></span>
                </div>

                <div class="field-box withdrawApply">
                    <label>二级密码：</label>
                    <input class="span6" type="password" id="Pass2" name="Pass2" placeholder="请输二级密码" value="" /><span class="alert-msg"></span>
                </div>

                <div class="field-box withdrawApply">
                    <label>邮箱：</label>
                    <input class="span6" type="text" id="IsEmail" name="IsEmail" placeholder="请输入邮箱" value="" /><span class="alert-msg"></span>
                </div>

                <div class="field-box withdrawApply">
                    <label>QQ：</label>
                    <input class="span6" type="text" id="QQ" name="QQ" placeholder="请输入QQ或者微信" value="" /><span class="alert-msg"></span>
                </div>

                <div class="span11 field-box actions">
                    <label></label>
                    <input type="button" class="btn-glow primary" id="btn_submit" value="确认提交">
                </div>
            </form>
            @*<div class="span11 field-box actions">
            <div class="col-md-10" style="text-align:center;font-weight:bold;font-size:20px;">添加后请联系客服进行审核！</div>
        </div>*@

        </div>
    </div>
</div>

<script>
    
    function SetTips(id, meg) {
        $("#" + id).next("span").html('<i class="icon-remove-sign"></i>' + meg);
        $("#" + id).next("span").show();
        $("#" + id).focus();
    }

    $(function () {

        $("#btn_submit").click(function () {
            
            $(".alert-msg").css("display", "none");
            var data = validate.serializeObject($("#form_data"));

            if (validate.isNull(data.MobilePhone)) {
                SetTips('MobilePhone', "请输入商户手机");
                return;
            }

            if (!validate.isMobile(data.MobilePhone))
            {
                SetTips('MobilePhone', "手机格式错误！");
                return;
            }

            if (validate.isNull(data.MerName)) {
                SetTips('MerName', "请输入商户名称");
                return;
            }

            if (validate.isNull(data.MerName)) {
                SetTips('MerName', "请输入商户名称");
                return;
            }

            if (validate.isNull(data.Pass)) {
                SetTips('Pass', "请输入登录密码");
                return;
            }

            if (data.Pass.length < 6 || data.Pass.length>18)
            {
                SetTips('Pass', "登录密码只能6-18位");
                return;
            }

            if (validate.isNull(data.Pass2)) {
                SetTips('Pass2', "请输入二级密码");
                return;
            }

            if (data.Pass2.length < 6 || data.Pass2.length > 18) {
                SetTips('Pass2', "二级密码只能6-18位");
                return;
            }
           
            $.HM.ajax("Business/AddUserBase", {
                data: data,
                type: "POST",
                dataType: 'json',
                success: function (d) {
                    if (d.IsSuccess) {
                        layer.msg("添加成功", { icon: 1 });
                        setTimeout(function () {
                            window.parent.location.reload();
                        }, 1500);

                    } else {
                        layer.msg(d.message, { icon: 0 });
                    }
                }
            });

        });

    });

</script>
